package org.example;

import org.example.bean.model.LoginParam;
import org.example.bean.model.LoginTypeEnum;
import org.example.bean.service.LoginCommonStragegyRegistry;
import org.example.bean.service.LoginStragegy;
import org.example.biz.AbstractFactory;
import org.example.biz.StageFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        noBean();
        ApplicationContext context = SpringApplication.run(Main.class, args);
        LoginCommonStragegyRegistry bean = context.getBean(LoginCommonStragegyRegistry.class);
        LoginStragegy loginStragegy = bean.mapGet().get(LoginTypeEnum.USERNAMETYPE);
        if (loginStragegy == null) {
            System.out.println("loginStragegy is null");
            return;
        }
        LoginParam loginParam = new LoginParam();
        loginStragegy.checkParam(loginParam);
        loginStragegy.login(loginParam);
    }

    public static void noBean() {
        StageFactory stageFactory = new StageFactory();
        AbstractFactory stage = stageFactory.createStage("11");
        if (stage == null) {
            System.out.println("Invalid stage type");
            return;
        }
        stage.func3();
    }
}